home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Startup Screen Picker 1.2 / source / ssp INIT ƒ / ssp code ƒ / really notify.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  2.7 KB  |  122 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        really notify.c
  4.  
  5. Purpose:    This module handles notifying the user that an error has
  6.             occurred (through the Notification Manager); also, displaying
  7.             the proper icon during init loading.
  8.             
  9. This program is free software; you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation; either version 2 of the License, or
  12. (at your option) any later version.
  13.  
  14. This program is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. GNU General Public License for more details.
  18.  
  19. You should have received a copy of the GNU General Public License
  20. along with this program in a file named "GNU General Public License".
  21. If not, write to the Free Software Foundation, 675 Mass Ave,
  22. Cambridge, MA 02139, USA.
  23.  
  24. \**********************************************************************/
  25.  
  26. #include "really notify.h"
  27. #include "show init.h"
  28. #include "environment.h"
  29.  
  30. #define        DEFAULT_MESSAGE        "\pStartup Screen Picker did not open because \
  31. an error occurred during startup.  The INIT may be damaged, \
  32. or there may not be enough memory in the system heap."
  33.  
  34. void StartupError(short errorcode)
  35. {
  36.     Str255            errorText;
  37.     Str255            errorNumber;
  38.     unsigned char    *defaultText = DEFAULT_MESSAGE;
  39.     unsigned char    *textPtr;
  40.     StringPtr        str;
  41.     short            size;
  42.     
  43.     if (gHasNotification)
  44.     {
  45.         SetZone(ApplZone);
  46.         GetIndString(errorText, STARTUP_ERROR_STR, errorcode);
  47.         SetZone(SysZone);
  48.         textPtr=(errorText[0]==0) ? defaultText : errorText;        
  49.         size = textPtr[0] + 1;
  50.         str = (StringPtr)NewPtrSys(size);
  51.         if(str)
  52.         {
  53.             BlockMove(textPtr, str, size);
  54.             
  55.             if(SetupNM(str))
  56.                 DisposePtr((Ptr)str);
  57.         }
  58.     }
  59.     
  60.     SetZone(ApplZone);
  61.     ShowBadICON();
  62.     SetZone(SysZone);
  63. }
  64.  
  65. void StartupGood(void)
  66. {
  67.     SetZone(ApplZone);
  68.     ShowGoodICON();
  69.     SetZone(SysZone);
  70. }
  71.  
  72. short SetupNM(StringPtr str)
  73. {
  74.     NMRec            *note;
  75.     Handle            nmResponse;
  76.     OSErr            isHuman;
  77.     long            gestaltReturn;
  78.     
  79.     if(str == (StringPtr)0L)
  80.         return 1;
  81.     
  82.     note = (NMRec*)NewPtrSys(sizeof(NMRec));
  83.     if(!note)
  84.     {
  85.         return 1;
  86.     }
  87.     else
  88.     {
  89.         note->qType = nmType;
  90.         note->nmMark = 0;
  91.         note->nmIcon = 0L;
  92.         note->nmSound = 0L;
  93.         note->nmStr = str;
  94.         
  95.         /* NMRP ID=RESPONSE_NMRP must be System Heap, Preload */
  96.         nmResponse = GetResource('NMRP', RESPONSE_NMRP);
  97.         if(!nmResponse)
  98.         {
  99.             DisposePtr(note);
  100.             return 1;
  101.         }
  102.         else
  103.         {
  104.             HLock(nmResponse);
  105.             HNoPurge(nmResponse);
  106.             DetachResource(nmResponse);
  107.             
  108.             note->nmResp = (ProcPtr)*nmResponse;
  109.             
  110.             if(NMInstall(note) == noErr)
  111.             {
  112.                 return 0;
  113.             }
  114.             else
  115.             {
  116.                 DisposePtr(note);
  117.                 return 1;
  118.             }
  119.         }
  120.     }
  121. }
  122.